package com.bw.controller;


import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.bw.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author ${郭冬胜}
 * @date 2025/8/6 9:00
 */
@RestController
public class UserController {
    @Autowired
    UserService userService;
    @RequestMapping("full")
    public Object t1(){
        List<Map> list =userService.full();
        JSONObject jsonObject1 = new JSONObject();
        jsonObject1.put("status",0);
        jsonObject1.put("msg","");
        JSONObject data = new JSONObject();
        JSONArray objects = new JSONArray();
        data.put("categories",objects);
        for (Map map : list) {
            objects.add(map.get("name"));
        }
        JSONArray objects1 = new JSONArray();
        data.put("series",objects1);
        JSONObject jsonObject11 = new JSONObject();
        jsonObject11.put("name","评价次数");
        objects1.add(jsonObject11);
        JSONArray objects2 = new JSONArray();
        jsonObject11.put("data",objects2);
        for (Map map : list) {
            objects2.add(map.get("c"));
        }


        jsonObject1.put("data",data);
        return jsonObject1;
    }


    @RequestMapping("fullA")
    public Object t2(){
        List<Map> list =userService.fullA();
        JSONObject jsonObject1 = new JSONObject();
        jsonObject1.put("status",0);
        jsonObject1.put("msg","");
        JSONObject data = new JSONObject();
        JSONArray objects = new JSONArray();
        data.put("categories",objects);
        for (Map map : list) {
            objects.add(map.get("name"));
        }
        JSONArray objects1 = new JSONArray();
        data.put("series",objects1);
        JSONObject jsonObject11 = new JSONObject();
        jsonObject11.put("name","平均评分");
        objects1.add(jsonObject11);
        JSONArray objects2 = new JSONArray();
        jsonObject11.put("data",objects2);
        for (Map map : list) {
            objects2.add(map.get("avg"));
        }


        jsonObject1.put("data",data);
        return jsonObject1;
    }
    @RequestMapping("fullB")
    public Object t3(){
        List<Map> list = userService.full();
        return list;
    }

    @RequestMapping("fullC")
    public Object t4(){
        List<Map> list = userService.fullC();
        return list;
    }

    @RequestMapping("fullD")
    public Object t5(){
        List<Map> list = userService.fullD();
        return list;
    }

    @RequestMapping("fullE")
    public Object t6(){
        List<Map> list = userService.fullA();
        return list;
    }




}
